package com.goldsprite.contourextraction.core;

import java.util.List;

public class ContourVisualizer {

	/**
	 * 简单的 ASCII 可视化
	 */
	public void visualizeContours(int[][] image, Contour contour) {
		int height = image.length;
		int width = image[0].length;

		List<int[]> points =  contour.points;

		char[][] display = new char[height][width];

		// 初始化显示数组
		for (int y = 0; y < height; y++) {
			for (int x = 0; x < width; x++) {
				display[y][x] = image[y][x] == ImageConstants.FOREGROUND ? 'o' : '·';
			}
		}

		// 标记轮廓点
		for (int[] point : points) {
			int x = point[0];
			int y = point[1];
			if (x >= 0 && y >= 0 && x < width && y < height) {
				display[y][x] = '●';
			}
		}

		// 打印结果
		for (int y = height-1; y >= 0; y--) {
			for (int x = 0; x < width; x++) {
				System.out.print(display[y][x] + "");
			}
			System.out.println();
		}
	}
}
